#include "room_pch.h"
#include "common.h"
#include "BaseWindow.h"

ROOM_BEGIN

BaseWindow::BaseWindow() {
	//std::cout<<reinterpret_cast<void*>(this)<<std::endl;
	_handle = ::CreateWindow(BaseWindowClass, _T("Hello"), WS_OVERLAPPEDWINDOW,
			100, 100, 400, 400, NULL, NULL, ::GetModuleHandle(NULL), 
			reinterpret_cast<void*>(this));
	//std::cout<<_handle<<std::endl;
	::ShowWindow(_handle, SW_SHOW);
	::UpdateWindow(_handle);
}

BaseWindow::~BaseWindow() {
	::DestroyWindow(_handle);
}

LRESULT BaseWindow::process_winow_message(WindowMessage * msg) {
	std::cout<<msg->_msg<<std::endl;
	switch(msg->_msg) {
	case WM_CREATE:
		_handle = msg->_hwnd;
		break;
	case WM_DESTROY:
		std::cout<<"quit"<<std::endl;
		::PostQuitMessage(0);
		break;
	default:
		return ::DefWindowProc(msg->_hwnd, msg->_msg, msg->_wparam, msg->_lparam);
	}
	return 0;
}

void BaseWindow::show(bool visible) {
	//std::cout<<_handle<<std::endl;
}

ROOM_END


